#include "NetIO.h"


int SockOps::set_non_blocking( EventHandle handle )
{
#ifdef WIN32
	u_long non_blocking = 1;
	return ioctlsocket( handle, FIONBIO, &non_blocking );
#else
	int opts = fcntl( handle, F_GETFL );

	if( opts & O_NONBLOCK )
		return 0;

	return fcntl( handle, F_SETFL, opts | O_NONBLOCK );
#endif
}

int SockOps::close_socket( EventHandle handle )
{
#ifdef WIN32
	return closesocket( handle );
#else
	return close( handle );
#endif
}

int SockOps::net_init( )
{
#ifdef WIN32
	WORD data = MAKEWORD( 2, 2 );
	WSADATA wsaData;
	WSAStartup( data, &wsaData );
#endif
	return 0;
}


